package com.dianwoba.springboot.dubbo.commands;

import com.dianwoba.goodies.lifecycle.ShutdownLatch;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.boot.CommandLineRunner;


public class DubboServiceLatchCommandLineRunner implements CommandLineRunner, DisposableBean {

    private String domain = "com.dianwoba.lifecycles";
    ShutdownLatch latch = null;

    @Override
    public void run(String... args) throws Exception {
        latch = new ShutdownLatch(getDomain());
        latch.await();
    }


    public String getDomain() {
        return domain;
    }

    public void setDomain(String domain) {
        this.domain = domain;
    }

    @Override
    public void destroy() throws Exception {
        latch.shutdown();
    }
}
